﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.IssueQuestLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class IssueQuestLogEntry : LogEntry
  {
    [SaveableField(10)]
    public readonly Hero IssueGiver;
    [SaveableField(20)]
    public readonly Hero Antagonist;
    [SaveableField(30)]
    public QuestBase.QuestCompleteDetails Details;

    internal static void AutoGeneratedStaticCollectObjectsIssueQuestLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this.IssueGiver);
      collectedObjects.Add((object) this.Antagonist);
    }

    internal static object AutoGeneratedGetMemberValueIssueGiver(object o)
    {
      return (object) ((IssueQuestLogEntry) o).IssueGiver;
    }

    internal static object AutoGeneratedGetMemberValueAntagonist(object o)
    {
      return (object) ((IssueQuestLogEntry) o).Antagonist;
    }

    internal static object AutoGeneratedGetMemberValueDetails(object o)
    {
      return (object) ((IssueQuestLogEntry) o).Details;
    }

    public override CampaignTime KeepInHistoryTime => CampaignTime.Weeks(1f);

    public IssueQuestLogEntry(
      Hero questGiver,
      Hero antagonist,
      QuestBase.QuestCompleteDetails status)
    {
      this.IssueGiver = questGiver;
      this.Antagonist = antagonist;
      this.Details = status;
    }

    public override void GetConversationScoreAndComment(
      Hero talkTroop,
      bool findString,
      out string comment,
      out ImportanceEnum score)
    {
      score = ImportanceEnum.Zero;
      comment = "";
      if (this.IssueGiver == talkTroop)
      {
        if (this.Details == QuestBase.QuestCompleteDetails.FailWithBetrayal)
        {
          score = ImportanceEnum.MatterOfLifeAndDeath;
          if (!findString)
            return;
          comment = "str_comment_quest_betrayed";
        }
        else if (this.Details == QuestBase.QuestCompleteDetails.Success)
        {
          score = ImportanceEnum.VeryImportant;
          if (!findString)
            return;
          comment = "str_comment_quest_succeeded";
        }
        else if (this.Details == QuestBase.QuestCompleteDetails.Fail || this.Details == QuestBase.QuestCompleteDetails.Timeout || this.Details == QuestBase.QuestCompleteDetails.Cancel)
        {
          score = ImportanceEnum.Important;
          if (!findString)
            return;
          comment = "str_comment_quest_failed";
        }
        else
        {
          if (this.Details != QuestBase.QuestCompleteDetails.Invalid)
            return;
          score = ImportanceEnum.ReasonablyImportant;
          if (!findString)
            return;
          comment = "str_comment_quest_invalid";
        }
      }
      else
      {
        if (this.Antagonist != talkTroop || this.Details != QuestBase.QuestCompleteDetails.FailWithBetrayal)
          return;
        score = ImportanceEnum.MatterOfLifeAndDeath;
        if (!findString)
          return;
        comment = "str_comment_quest_counteroffer_accepted";
      }
    }
  }
}
